﻿package frEngine.effectEditTool.temple
{
    import flash.geom.*;
    import frEngine.math.*;

    public class FightParams extends Object
    {
        public var uid:String;
        public var startTargetLabel:String;
        public var startBoneName:String;
        public var endTargetLabel:String;
        public var endBoneName:String;
        public var fightSpeed:Number = 0;
        public var startPos:Vector3D;
        public var endPos:Vector3D;
        public var next:FightParams;
        public var lineType:String;
        public var openAngle:Number;
        public var rotateAngle:Number;
        public var midHerizionRate:Number;
        public var midHeightRate:Number;
        public var staticFaceTarget:Boolean = false;
        public var keepGoing:Boolean = false;
        public var followTarget:Boolean = true;
        private static const qu:Quaternion = new Quaternion();
        private static const _temp:Vector3D = new Vector3D();

        public function FightParams(param1:Object)
        {
            var _loc_4:Array = null;
            this.uid = param1.uid;
            var _loc_2:* = param1.startPos.split("||");
            this.startTargetLabel = _loc_2[0];
            var _loc_3:* = this.startTargetLabel.indexOf("#");
            if (_loc_3 != -1)
            {
                this.startTargetLabel = this.startTargetLabel.substr((_loc_3 + 1));
            }
            this.startBoneName = _loc_2[1];
            _loc_2 = param1.endPos.split("||");
            this.endTargetLabel = _loc_2[0];
            _loc_3 = this.endTargetLabel.indexOf("#");
            if (_loc_3 != -1)
            {
                this.endTargetLabel = this.endTargetLabel.substr((_loc_3 + 1));
            }
            this.endBoneName = _loc_2[1];
            var _loc_5:* = param1.speed;
            if (_loc_5 <= 0)
            {
                _loc_5 = 5;
            }
            this.lineType = param1.lineType;
            this.openAngle = param1.openAngle;
            var _loc_6:int = 60;
            this.openAngle = 60;
            var _loc_6:int = -60;
            this.openAngle = -60;
            this.openAngle = this.openAngle / 180 * Math.PI;
            this.fightSpeed = _loc_5 / Math.cos(this.openAngle);
            this.rotateAngle = param1.rotateAngle;
            this.rotateAngle = this.rotateAngle / 180 * Math.PI;
            this.midHerizionRate = param1.mid0;
            this.midHeightRate = param1.mid1;
            this.keepGoing = param1.keepGoing;
            this.followTarget = param1.hasOwnProperty("followTarget") ? (param1.followTarget) : (true);
            this.staticFaceTarget = param1.staticFaceTarget;
            if (param1.next)
            {
                this.next = new FightParams(param1.next);
            }
            return;
        }// end function

        public function get curveMidPos() : Vector3D
        {
            var _loc_4:Vector3D = null;
            var _loc_1:* = this.endPos.subtract(this.startPos);
            var _loc_2:* = _loc_1.normalize();
            var _loc_3:* = _loc_1.dotProduct(Vector3D.Y_AXIS);
            if (_loc_3 > 0.9)
            {
                _loc_4 = Vector3D.X_AXIS.crossProduct(_loc_1);
            }
            else
            {
                _loc_4 = _loc_1.crossProduct(Vector3D.Y_AXIS);
            }
            var _loc_5:* = _loc_4.crossProduct(_loc_1);
            _loc_5.normalize();
            _loc_1.crossProduct(_loc_5);
            _loc_5.scaleBy(_loc_2 * this.midHeightRate);
            qu.fromAxisAngle(_loc_1, this.rotateAngle);
            qu.rotatePoint(_loc_5, _temp);
            _loc_1.scaleBy(_loc_2 * this.midHerizionRate);
            _loc_1 = this.startPos.add(_loc_1);
            var _loc_6:* = _loc_1.add(_temp);
            return _loc_6;
        }// end function

    }
}
